clear
* Place filepath to replication data here
insheet using "\repdata.csv"

* set up panel
encode state, gen(ST)
xtset ST year

* main analysis producing Table 1 in paper
est clear
eststo: areg lr union i.year  [aweight=employment], absorb(ST) cluster(ST)
eststo: areg lr L2.policy union i.year  [aweight=employment], absorb(ST) cluster(ST)
eststo: areg lr L2.policy c.union c.pct*  i.year [aweight=employment],  absorb(ST) cluster(ST)
eststo: ivreg2 lr L2.policy c.pct* i.year i.ST (union=rtw) [aweight=employm], first gmm2s cluster(ST) partial(i.ST)
* reduced form
eststo: areg lr rtw c.pct* L2.pol i.year [aweight=employment],  absorb(ST) cluster(ST)
* make table
esttab, se label stats(N rmse) title(Regression table\label{tab1})

* robustness check using original unscaled variable
areg rate c.union i.year [aweight=employment], absorb(ST) cluster(ST)
areg rate c.union L2.policy i.year [aweight=employment], absorb(ST) cluster(ST)
areg rate c.union L2.policy pct* i.year [aweight=employment], absorb(ST) cluster(ST)
ivreg2 rate L2.policy c.pct* i.year i.ST (union=rtw) [aweight=employm], first gmm2s cluster(ST) partial(i.ST)
* reduced form
areg rate L2.policy rtw c.pct*  i.year  [aweight=employment], cluster(ST) absorb(ST)
est clear
